/*-+-*****************************************************************************
 Copyright (C) 2009-2012 Oceanside Software Corporation (R)
 Dallas, Texas

 Author       : Jason T. Brower
 Purpose      : This file is part of a point-of-sale software package
                originally written for Table-Service Restaurants.
              
 Date         : July 8th of 2012
              
 History      : The application that this software file belongs to was 
                written over a 3-Year period.  The first version was written
                in C# .Net 3.5 using Windows Forms.  Being new to .Net at
                the time, I soon learned of Windows Presentation Foundation,
                liked the graphics capabilities and databinding so I
                migrated to WPF.  When the .Net 4.0 framework was released
                the application was migrated from 3.5 to 4.0. Now today,
                .Net 4.5 RC is out and I was already in process of migrating
                before I made this public.
                
Excuse Me     : Please excuse the coding style, it is not representative of
                my typical work.  During the three years I was under a very
                tight budget, constantly running out of funding and was 
                working 18 hour days hyped up on 5-Hour Energy.  The 
                design is not textbook.  It is monolythic because of
                previous issues I will not get into.  There are few comments
                in the code and the ones that are there may be incorrect.
                
What it is not: This is not the exact version that I took through PA-DSS 2.0
                nor is it the exact version running at my customer sites.
                I removed some details for security purposes including some
                encryption algorithms.  The reporting was removed because
                I was including a third party library that cannot be 
                published with this Open Source.
                
What it is    : This application has been running at high volume restaraunts
                for over a year.  It never freezes, crashes or does anything
                unexpected.  So long as it is built, installed and configured
                correctly, it is a strong system that we can all enhance.

Contact       : Please note that I can no longer work for free.  However, you
                can reach me at information@oceansidesw.com.                                                      

*********************************************************************************/
#if _LOCALDB
  using Oceanside.LocalDB;
#else
using Oceanside.RemoteDB;
#endif
namespace Oceanside
{
    public class CREDIT_TRANSACTION_PRINT_PACKET
    {
        public TRANSACTION Transaction;
        public TRANSACTION_RESPONSE TransactionResponse;
    }

    public class PrintConst
    {
        public const int MAX_LINE_WIDTH = 39;

        public static readonly string GTOTALTRANSSTR = "Transaction Count:";
        public static readonly string GTOTALPRODSTR = "Grand Total Pretax:";
        public static readonly string GTOTALTAXSTR = "Grand Total Tax:";
        public static readonly string GTOTALTIPSTR = "Grand Total Tips:";
        public static readonly string GTOTALPROCSTR = "Processor Total:";

        public static readonly string TOTALSTR= "Total:";
        public static readonly string CASHTNDRSTR = "Cash Tendered:";
        public static readonly string CHECKTNDRSTR = "Check Tendered:";
        public static readonly string CHANGESTR = "Change:";
        public static readonly string CRDSTR = "Credit:";
        public static readonly string TAXSTR = "Tax:";
        public static readonly string SUBTOTALSTR = "Subtotal:";
        public static readonly string EQUALPAYSTR = "Equal Payment Count:";
        public static readonly string PAIDSTR = "Payment Amount:";
        public static readonly string GCBALANCE = "Giftcard Balance:";
        public static readonly string TIPSTR = "Tip:";
        public static readonly string GRATUITY = "Gratuity:";
        public static readonly string AMOUNTLINESTR = "$______________.____";
        public static readonly string OCEANSIDE_TRANSIDSTR = "TRID:";
        public static readonly string OCEANSIDE_INVOICEIDSTR = "INVOICE:";
        public static readonly string TYPESTR = "Card Type:";
        public static readonly string CUSTNAME = "Cardholder:";
        public static readonly string TRANSTYPE = "Transaction Type:";
        public static readonly string PAYTIME = "Payment Time:";
        public static readonly string CARDNUMSTR = "Card Number:";
        public static readonly string CARDXSTR = "XXXXXXXXXXX";
        public static readonly string AUTHSTR = "Authorization:";
        public static readonly string INVOICEIDSTR = "INVOICE:";

        public static readonly string JOBCODESTR = "ROLE ID/JOB CODE |"; 
        public const int JOBCODESTRSIZE = 18;
        public static readonly string HOURSSTR = " HOURS  ";
        public const int HOURSSTRSIZE = 8;
        public static readonly string GROSSSTR = "|   GROSS    ";
        public const int GROSSSTRSIZE = 13;
        public static readonly string PAYROLLHEADERSTR = JOBCODESTR + HOURSSTR + GROSSSTR;


        public static void BuildBatchCloseDisplay(System.Text.StringBuilder sb, BATCH_CLOSE_RESPONSE resp)
        {
            string tmp;

            sb.AppendLine();
            sb.Append("     **** Credit Batch Report **** " + PrintConst.NL + PrintConst.NL);
            sb.Append("Batch Number:");
            tmp = resp.BatchNo.ToString();
            Helpers.PaddWithChar(sb, MAX_LINE_WIDTH - ("Batch Number:".Length + tmp.Length), ' ');
            sb.AppendLine(tmp);
            Helpers.PaddWithChar(sb, PrintConst.MAX_LINE_WIDTH, '-');

            sb.Append("Batch Item Count:");
            tmp = resp.BatchItemCount.ToString();
            Helpers.PaddWithChar(sb, MAX_LINE_WIDTH - ("Batch Item Count:".Length + tmp.Length), ' ');
            sb.AppendLine(tmp);

            sb.Append("Credit Purchase Count:");
            tmp = resp.CreditPurchaseCount.ToString();
            Helpers.PaddWithChar(sb, MAX_LINE_WIDTH - ("Credit Purchase Count:".Length + tmp.Length), ' ');
            sb.AppendLine(tmp);

            sb.Append("Credit Return Count:");
            tmp = resp.CreditReturnCount.ToString();
            Helpers.PaddWithChar(sb, MAX_LINE_WIDTH - ("Credit Return Count:".Length + tmp.Length), ' ');
            sb.AppendLine(tmp);

            sb.Append("Debit Purchase Count:");
            tmp = resp.DebitPurchaseCount.ToString();
            Helpers.PaddWithChar(sb, MAX_LINE_WIDTH - ("Debit Purchase Count:".Length + tmp.Length), ' ');
            sb.AppendLine(tmp);

            sb.Append("Debit Return Count:");
            tmp = resp.DebitReturnCount.ToString();
            Helpers.PaddWithChar(sb, MAX_LINE_WIDTH - ("Debit Return Count:".Length + tmp.Length), ' ');
            sb.AppendLine(tmp);
            Helpers.PaddWithChar(sb, PrintConst.MAX_LINE_WIDTH, '-');

            sb.Append("Credit Purchase Amount:");
            tmp = resp.CreditPurchaseAmountDec.ToString("c");
            Helpers.PaddWithChar(sb, MAX_LINE_WIDTH - ("Credit Purchase Amount:".Length + tmp.Length), ' ');
            sb.AppendLine(tmp);

            sb.Append("Credit Return Amount:");
            tmp = resp.CreditReturnAmountDec.ToString("c");
            Helpers.PaddWithChar(sb, MAX_LINE_WIDTH - ("Credit Return Amount:".Length + tmp.Length), ' ');
            sb.AppendLine(tmp);

            sb.Append("Debit Purchase Amount:");
            tmp = resp.DebitPurchaseAmountDec.ToString("c");
            Helpers.PaddWithChar(sb, MAX_LINE_WIDTH - ("Debit Purchase Amount:".Length + tmp.Length), ' ');
            sb.AppendLine(tmp);

            sb.Append("Debit Return Amount:");
            tmp = resp.DebitReturnAmountDec.ToString("c");
            Helpers.PaddWithChar(sb, MAX_LINE_WIDTH - ("Debit Return Amount:".Length + tmp.Length), ' ');
            sb.AppendLine(tmp);

            sb.Append("---------------------------------------\n");
            sb.Append("Net Batch Total:");
            tmp = resp.NetBatchTotalDec.ToString("c");
            Helpers.PaddWithChar(sb, MAX_LINE_WIDTH - ("Net Batch Total:".Length + tmp.Length), ' ');
            sb.AppendLine(tmp + Constants.NEWLINE);
            sb.AppendLine("Please note that any transactions that");
            sb.AppendLine("were approved on Mercury's stand-in ");
            sb.AppendLine("servers known as \"MercX\" transactions");
            sb.AppendLine("while the processor's network was down");
            sb.AppendLine("will be funded but will not show in");
            sb.AppendLine("this batch report." + Constants.NEWLINE);
        }


        public static readonly string EMPSIG = "Signature X";
        public static readonly string MANSIG = "Cash Given To X";
        public static readonly string CUSTSIG = "Customer X";


        /// <summary>
        /// For ESC/POS
        /// </summary>
        public static readonly string INIT = "\x1b\x40";
        public static readonly string RED = "\x1b\x72\x01";
        public static readonly string BLACK = "\x1b\x72\x00";
        public static readonly string BOLD = "\x1b\x45\x01";
        public static readonly string NORMAL = "\x1b\x45\x00";
        public static readonly string LEFT = "\x1b\x61\x00";
        public static readonly string CENTER = "\x1b\x61\x01";
        public static readonly string RIGHT = "\x1b\x61\x02";
        public static readonly string FEED10 = "\x1b\x64\x0A";
        public static readonly string FEED5 = "\x1b\x64\x05";
        public static readonly string FEED4 = "\x1b\x64\x04";
        public static readonly string CUTPAPER = "\x1d\x56\x42\x00";
        public static readonly string RETHOME = "\x1b\x3c";
        public static readonly string NL = "\n";
        public static readonly string CR = "\r";      
        public static readonly string DRAWER1 = "\x1b\x70\x0\x32\x64";
        public static readonly string DRAWER2 = "\x1b\x70\x1\x32\x64";
        public static readonly string PRINTLOGO = "\x1d\x28\x4c\x6\x0\x30\x45\x20\x20\x1\x1";
        public static readonly string DBLHIGH_DBLWIDE_ON = "\x1b\x21\x16";
        public static readonly string DBLHIGH_DBLWIDE_OFF = "\x1b\x21\x1";
    }
}
